package de.ryancarmon.validator.cfg;

import java.util.HashMap;
import java.util.Map;

public final class ValidatorConfig {
	private static ValidatorConfig instance;
	
	private Map<ConfigValue, Object> cfgValues;
	
	private ValidatorConfig() {
		cfgValues = new HashMap<ConfigValue, Object>();
	}
	
	private Object doGet(ConfigValue key) {
		return cfgValues.get(key);
	}
	
	private void doSet(ConfigValue key, Object value) {
		cfgValues.put(key, value);
	}
	
	private void doRemove(ConfigValue key) {
		cfgValues.remove(key);
	}
	
	private static ValidatorConfig instance() {
		if(instance==null) {
			synchronized(ValidatorConfig.class) {
				if(instance==null) {
					instance = new ValidatorConfig();
				}
			}
		}
		
		return instance;
	}
	
	public static Object get(ConfigValue key) {
		return instance().doGet(key);
	}
	
	public static void put(ConfigValue key, Object value) {
		instance().doSet(key, value);
	}
	
	public static void remove(ConfigValue key) {
		instance().doRemove(key);
	}
}
